package org.xx.armory.swing.builders;

import org.xx.armory.objectparser.LineInfo;
import org.xx.armory.objectparser.ParsedObject;
import org.xx.armory.swing.components.BorderType;

import static org.apache.commons.lang3.StringUtils.trimToEmpty;
import static org.xx.armory.commons.Validators.notNull;

public abstract class AbstractLayoutModel
        extends ParsedObject
        implements ComponentModel {
    private final String name;
    private final boolean visible;
    private final String title;
    private final BorderType border;

    protected AbstractLayoutModel(
            LineInfo lineInfo,
            String name,
            boolean visible,
            String title,
            BorderType border
    ) {
        super(lineInfo);
        this.name = trimToEmpty(name);
        this.visible = visible;
        this.title = title != null ? title : "";
        this.border = notNull(border, "border");
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public final String getName() {
        return this.name;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public final boolean isVisible() {
        return this.visible;
    }

    public final String getTitle() {
        return this.title;
    }

    public final BorderType getBorder() {
        return this.border;
    }
}
